Ext.require([
        'Ext.menu.Menu',
        'Ext.menu.Item',
        'Ext.form.Label'
    ]);


function createRicercaMenu(role,context){
	var panel;
	
  if (role=='ROLE_ADMIN' && context=='candidato'){
	
	panel = new Ext.panel.Panel({
        collapseDirection: 'left',
        collapsible: true,
        title: 'Menu',
        titleCollapse: true,
        collapsed:true,
        region: 'west',
		width: 140,
		height:230,
		renderTo:'sideMenu',
		items:[{
			xtype: 'menu',
	        width: 140,
	      	height:230,
	        bodyStyle: 'opacity:0.5',
	        floating: false,
	        items: [
                        {
                            xtype: 'menuitem',
                            itemId: 'home',
                            width: 140,
                            height:30,
                            text: 'Ricerca',
                            bodyStyle: 'opacity:0.5',
                            listeners:{
                            	click : function(i,e){
                            		$("<input>").attr("name","_eventId").css("display","none").val("go-to-ricerca").appendTo($("#navigationForm"));
                            		document.getElementById("navigationForm").submit();
                            	}
                            }
                        },
                        {
                            xtype: 'menuitem',
                            itemId: 'about',
                            width: 140,
                            height:30,
                            text: 'Aziende',
                            bodyStyle: 'opacity:0.5',
                            listeners:{
                            	click : function(i,e){
                            		$("<input>").attr("name","_eventId").css("display","none").val("go-to-ricerca-aziende").appendTo($("#navigationForm"));
                            		document.getElementById("navigationForm").submit();
                            	}
                            }
                        },
                        {
                            xtype: 'menuitem',
                            itemId: 'contact',
                            width: 140,
                            height:30,
                            bodyStyle: 'opacity:0.5',
                            text: 'Opportunita',
                            listeners:{
                            	click : function(i,e){
                            		$("<input>").attr("name","_eventId").css("display","none").val("go-to-ricerca-opportunita").appendTo($("#navigationForm"));
                            		document.getElementById("navigationForm").submit();
                            	}
                            }
                        },
                        {
                            xtype: 'menuitem',
                            itemId: 'admin',
                            width: 140,
                            height:30,
                            bodyStyle: 'opacity:0.5',
                            text: 'Admin',
                            listeners:{
                            	click : function(i,e){
                            		$("<input>").attr("name","_eventId").css("display","none").val("go-to-admin").appendTo($("#navigationForm"));
                            		document.getElementById("navigationForm").submit();
                            	}
                            }
                        },
                        {
                            xtype: 'menuitem',
                            itemId: 'docs',
                            width: 140,
                            height:30,
                            bodyStyle: 'opacity:0.5',
                            text: 'Stampe',
                            floating: false,
                            menu: {
                    	        items: [
                                        {
                                            xtype: 'menuitem',
                                            itemId: 'cv-long',
                                            width: 140,
                                            height:30,
                                            text: 'CV Long',
                                            bodyStyle: 'opacity:0.5',
                                            listeners:{
                                            	click : function(i,e){
                                            		$("#printForm").empty();
                                            		$("<input>").attr("name","_eventId").css("display","none").val("print-cv-long").appendTo($("#printForm"));
                                            		document.getElementById("printForm").target="_blank";
                                            		document.getElementById("printForm").submit();
                                            	}
                                            }
                                        },
                                        {
                                            xtype: 'menuitem',
                                            itemId: 'cv-short',
                                            width: 140,
                                            height:30,
                                            text: 'CV Short',
                                            bodyStyle: 'opacity:0.5',
                                            menu: {
                                    	        items: [
                                                        {
                                                            xtype: 'menuitem',
                                                            itemId: 'cv-short-logo',
                                                            width: 140,
                                                            height:30,
                                                            text: 'Con Logo',
                                                            bodyStyle: 'opacity:0.5',
                                                            listeners:{
                                                            	click : function(i,e){
                                                            		$("#printForm").empty();
                                                            		$("<input>").attr("name","_eventId").css("display","none").val("print-cv-short-logo").appendTo($("#printForm"));
                                                            		document.getElementById("printForm").target="_blank";
                                                            		document.getElementById("printForm").submit();
                                                            	}
                                                            }
                                                        },
                                                        {
                                                            xtype: 'menuitem',
                                                            itemId: 'cv-short-nologo',
                                                            width: 140,
                                                            height:30,
                                                            text: 'Senza Logo',
                                                            bodyStyle: 'opacity:0.5',
                                                            listeners:{
                                                            	click : function(i,e){
                                                            		$("#printForm").empty();
                                                            		$("<input>").attr("name","_eventId").css("display","none").val("print-cv-short-nologo").appendTo($("#printForm"));
                                                            		document.getElementById("printForm").target="_blank";
                                                            		document.getElementById("printForm").submit();
                                                            	}
                                                            }
                                                        }
                                                     ]
                                            }
                                        },
                                        {
                                            xtype: 'menuitem',
                                            itemId: 'cv-analisi',
                                            width: 140,
                                            height:30,
                                            text: 'Analisi',
                                            bodyStyle: 'opacity:0.5',
                                            listeners:{
                                            	click : function(i,e){
                                            		$("#printForm").empty();
                                            		$("<input>").attr("name","_eventId").css("display","none").val("print-cv-analisi").appendTo($("#printForm"));
                                            		document.getElementById("printForm").target="_blank";
                                            		document.getElementById("printForm").submit();
                                            	}
                                            }
                                        }
                                    ]
                            }
                        }
                    ]
			}]
	   });
    }else if(role=='ROLE_ADMIN'&&context!='candidato'){
    	panel = new Ext.panel.Panel({
            collapseDirection: 'left',
            collapsible: true,
            title: 'Menu',
            titleCollapse: true,
            collapsed:true,
            region: 'west',
    		width: 140,
    		height:230,
    		renderTo:'sideMenu',
    		items:[{
    			xtype: 'menu',
    	        width: 140,
    	      	height:230,
    	        bodyStyle: 'opacity:0.5',
    	        floating: false,
    	        items: [
                            {
                                xtype: 'menuitem',
                                itemId: 'home',
                                width: 140,
                                height:30,
                                text: 'Ricerca',
                                bodyStyle: 'opacity:0.5',
                                listeners:{
                                	click : function(i,e){
                                		$("<input>").attr("name","_eventId").css("display","none").val("go-to-ricerca").appendTo($("#navigationForm"));
                                		document.getElementById("navigationForm").submit();
                                	}
                                }
                            },
                            {
                                xtype: 'menuitem',
                                itemId: 'about',
                                width: 140,
                                height:30,
                                text: 'Aziende',
                                bodyStyle: 'opacity:0.5',
                                listeners:{
                                	click : function(i,e){
                                		$("<input>").attr("name","_eventId").css("display","none").val("go-to-ricerca-aziende").appendTo($("#navigationForm"));
                                		document.getElementById("navigationForm").submit();
                                	}
                                }
                            },
                            {
                                xtype: 'menuitem',
                                itemId: 'contact',
                                width: 140,
                                height:30,
                                bodyStyle: 'opacity:0.5',
                                text: 'Opportunita',
                                listeners:{
                                	click : function(i,e){
                                		$("<input>").attr("name","_eventId").css("display","none").val("go-to-ricerca-opportunita").appendTo($("#navigationForm"));
                                		document.getElementById("navigationForm").submit();
                                	}
                                }
                            },
                            {
                                xtype: 'menuitem',
                                itemId: 'admin',
                                width: 140,
                                height:30,
                                bodyStyle: 'opacity:0.5',
                                text: 'Admin',
                                listeners:{
                                	click : function(i,e){
                                		$("<input>").attr("name","_eventId").css("display","none").val("go-to-admin").appendTo($("#navigationForm"));
                                		document.getElementById("navigationForm").submit();
                                	}
                                }
                            }
                    ]
    		}]
    	});
    	
    }else if(role=='ROLE_USER'&&context=='candidato'){
    	panel = new Ext.panel.Panel({
            collapseDirection: 'left',
            collapsible: true,
            title: 'Menu',
            titleCollapse: true,
            collapsed:true,
            region: 'west',
    		width: 140,
    		height:230,
    		renderTo:'sideMenu',
    		items:[{
    			xtype: 'menu',
    	        width: 140,
    	      	height:230,
    	        bodyStyle: 'opacity:0.5',
    	        floating: false,
    	        items: [{
                    xtype: 'menuitem',
                    itemId: 'docs',
                    width: 140,
                    height:30,
                    bodyStyle: 'opacity:0.5',
                    text: 'Stampe',
                    floating: false,
                    menu: {
            	        items: [
                                {
                                    xtype: 'menuitem',
                                    itemId: 'cv-long',
                                    width: 140,
                                    height:30,
                                    text: 'CV Long',
                                    bodyStyle: 'opacity:0.5',
                                    listeners:{
                                    	click : function(i,e){
                                    		$("#printForm").empty();
                                    		$("<input>").attr("name","_eventId").css("display","none").val("print-cv-long").appendTo($("#printForm"));
                                    		document.getElementById("printForm").target="_blank";
                                    		document.getElementById("printForm").submit();
                                    	}
                                    }
                                },
                                {
                                    xtype: 'menuitem',
                                    itemId: 'cv-short',
                                    width: 140,
                                    height:30,
                                    text: 'CV Short',
                                    bodyStyle: 'opacity:0.5',
                                    listeners:{
                                    	click : function(i,e){
                                    		$("#printForm").empty();
                                    		$("<input>").attr("name","_eventId").css("display","none").val("print-cv-short").appendTo($("#printForm"));
                                    		document.getElementById("printForm").target="_blank";
                                    		document.getElementById("printForm").submit();
                                    	}
                                    }
                                },
                                {
                                    xtype: 'menuitem',
                                    itemId: 'cv-analisi',
                                    width: 140,
                                    height:30,
                                    text: 'Analisi',
                                    bodyStyle: 'opacity:0.5',
                                    listeners:{
                                    	click : function(i,e){
                                    		$("#printForm").empty();
                                    		$("<input>").attr("name","_eventId").css("display","none").val("print-cv-analisi").appendTo($("#printForm"));
                                    		document.getElementById("printForm").target="_blank";
                                    		document.getElementById("printForm").submit();
                                    	}
                                    }
                                }
                            ]
                    }
                }]
    		}]
    	});	    	
    }
		
	return panel;
}